package com.huawei.appgallery.assistantdock.base.cardkit.card;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.a;
import androidx.recyclerview.widget.RecyclerView.n;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.assistantdock.base.cardkit.bean.BuoyHorizonBaseBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import o.beo$a;
import o.beo$e;
import o.cgz;
import o.chy;
import o.ContentManager;
import o.eix;
import o.eiy;
import o.MinimumFactory;

public abstract class BuoyHorizonBaseCard extends BuoyBaseCard {
    protected a ˊ;
    public RecyclerView ˋ;
    protected eix ˎ = new eix();
    public LinearLayoutManager ˏ;
    protected chy ॱ;

    public abstract class c extends a<d> {
        final /* synthetic */ BuoyHorizonBaseCard ˎ;

        public class d extends s {
            protected View ʻॱ;
            final /* synthetic */ c ॱᐝ;

            public d(c cVar, View view) {
                this.ॱᐝ = cVar;
                super(view);
                this.ʻॱ = view;
            }
        }

        protected abstract void ˊ(d dVar, int i);

        protected abstract d ˏ(ViewGroup viewGroup, int i);

        protected c(BuoyHorizonBaseCard buoyHorizonBaseCard) {
            this.ˎ = buoyHorizonBaseCard;
        }

        @NonNull
        public /* synthetic */ s ˎ(@NonNull ViewGroup viewGroup, int i) {
            return ॱ(viewGroup, i);
        }

        public /* synthetic */ void ॱ(s sVar, int i) {
            ˏ((d) sVar, i);
        }

        @NonNull
        public d ॱ(@NonNull ViewGroup viewGroup, int i) {
            d ˏ = ˏ(viewGroup, i);
            if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
                ˏ.ʻॱ.setLayoutDirection(1);
            }
            return ˏ;
        }

        public void ˏ(d dVar, int i) {
            ˊ(dVar, i);
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) dVar.ʻॱ.getLayoutParams();
            if (marginLayoutParams != null) {
                ˊ(i, marginLayoutParams);
                dVar.ʻॱ.setLayoutParams(marginLayoutParams);
            }
        }

        private void ˊ(int i, MarginLayoutParams marginLayoutParams) {
            marginLayoutParams.setMarginEnd(0);
            if (i == 0) {
                marginLayoutParams.setMarginStart(this.ˎ.ˎ.ॱ());
                return;
            }
            if (i == ˏ() - 1) {
                marginLayoutParams.setMarginEnd(this.ˎ.ˎ.ॱ());
            }
            marginLayoutParams.setMarginStart(this.ˎ.ˎ.ॱॱ());
        }
    }

    protected abstract a ˊ();

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public BuoyHorizonBaseCard(Context context) {
        super(context);
        this.ˎ.ˎ(context.getResources().getDimensionPixelSize(beo$a.ˊ));
        this.ˎ.ᐝ(context.getResources().getDimensionPixelSize(beo$a.ˋ));
    }

    public BuoyBaseCard ˎ(View view) {
        ʽ(view);
        ˏ((RecyclerView) view.findViewById(beo$e.ˊ));
        this.ˊ = ˊ();
        this.ˏ = new LinearLayoutManager(view.getContext(), 0, false);
        ˋ().setLayoutManager(this.ˏ);
        if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
            ˋ().setLayoutDirection(0);
            this.ˏ.ˊ(true);
        }
        ˋ().setAdapter(this.ˊ);
        new eiy().ˏ(ˋ());
        ʽ();
        return this;
    }

    public RecyclerView ˋ() {
        return this.ˋ;
    }

    public void ˏ(RecyclerView recyclerView) {
        this.ˋ = recyclerView;
    }

    public chy ˏ() {
        return this.ॱ;
    }

    public void ॱ() {
    }

    public void ॱ(chy o_chy) {
        this.ॱ = o_chy;
    }

    protected void ˊ(CardBean cardBean) {
        ((TextView) this.ˊˋ.findViewById(beo$e.ॱ)).setText(cardBean.v_());
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        ˊ(cardBean);
        if ((cardBean instanceof BuoyHorizonBaseBean) && this.ˏ != null) {
            BuoyHorizonBaseBean buoyHorizonBaseBean = (BuoyHorizonBaseBean) cardBean;
            this.ˏ.ॱ(buoyHorizonBaseBean.ˊ(), buoyHorizonBaseBean.ʽ());
        }
        if (this.ˊ != null) {
            this.ˊ.ˊ();
        }
    }

    private void ʽ() {
        if (this.ˋ != null) {
            this.ˋ.ॱ(new n(this) {
                final /* synthetic */ BuoyHorizonBaseCard ॱ;

                {
                    this.ॱ = r1;
                }

                public void ˎ(RecyclerView recyclerView, int i) {
                    if (i == 0) {
                        CardBean ˌ = this.ॱ.ˌ();
                        if ((ˌ instanceof BuoyHorizonBaseBean) && this.ॱ.ˏ != null) {
                            BuoyHorizonBaseBean buoyHorizonBaseBean = (BuoyHorizonBaseBean) ˌ;
                            Boolean valueOf = Boolean.valueOf(this.ॱ.ˏ.ॱˎ() == this.ॱ.ˏ.ˌ() + -1);
                            int ॱˎ = this.ॱ.ˏ.ॱˎ();
                            this.ॱ.ˎ.ॱॱ(this.ॱ.ˏ.ॱˊ());
                            this.ॱ.ˎ.ʻ(this.ॱ.ˋ().getLeft());
                            if (valueOf.booleanValue()) {
                                buoyHorizonBaseBean.ˊ(ॱˎ);
                                buoyHorizonBaseBean.ˎ(this.ॱ.ˎ.ʻ());
                            } else {
                                buoyHorizonBaseBean.ˎ(this.ॱ.ˎ.ʻ());
                                buoyHorizonBaseBean.ˊ(this.ॱ.ˎ.ᐝ());
                            }
                            this.ॱ.ॱ();
                        }
                    }
                }
            });
        }
    }
}
